<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('项目详情')" />
	<th:block th:include="include :: select2-css" />
</head>

<body>
    <div class="main-content">
        <form class="form-horizontal"  id="form-user-edit" th:object="${basWarehouse}">

           <!-- [[${item}]]-->

                <input name="warehouse_id" type="hidden" th:field="*{warehouse_id}"/>

                <h4 class="form-header h4">基本信息</h4>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label is-required">仓库编号：</label>
                            <div class="col-sm-8">
                                <input name="warehouse_no" th:field="*{warehouse_no}" placeholder="请输入仓库编号" class="form-control" type="text" maxlength="30"
                                       required>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">项目编号：</label>
                            <div class="col-sm-8">
                                <input name="project_no" th:field="*{project_no}" placeholder="请输入项目编号" class="form-control" type="text" maxlength="30"
                                      >
                            </div>
                        </div>
                    </div>
                   <!-- <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">项目组：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input name="prjgroupId" th:field="*{prjgroupId}" onclick="selectDeptTree()" id="treeName" type="text"
                                           placeholder="请选择项目组" class="form-control">
                                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>-->
                </div>

                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label is-required">仓库名称：</label>
                            <div class="col-sm-8">
                                <input name="warehouse_name"  th:field="*{warehouse_name}"  placeholder="请输入仓库名称" class="form-control" type="text" maxlength="30"
                                       required>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">仓库地址：</label>
                            <div class="col-sm-8">
                                <input id="address" name="address" th:field="*{address}" placeholder="请输入仓库地址" class="form-control"
                                       type="text" maxlength="30">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">

                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">仓库描述：</label>
                            <div class="col-sm-8">
                                <input id="c_desc" name="c_desc"th:field="*{c_desc}"  placeholder="请输入仓库描述" class="form-control" type="text"
                                       maxlength="30">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">仓库级别：</label>
                                <div class="col-sm-8">
                                    <input id="warehouse_kind" name="warehouse_kind"th:field="*{warehouse_kind}"  placeholder="请输入仓库级别" class="form-control" type="text"
                                           maxlength="30">
                                </div>
                            </div>
                    </div>
                </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">仓库种类：</label>
<!--                        <input name="prjgroupId" type="hidden" id="prjgroupId" th:field="*{prjgroupId}"/>-->
                        <div class="col-sm-8">
                            <input id="warehouse_type" name="warehouse_type"th:field="*{warehouse_type}"  placeholder="请输入仓库种类" class="form-control" type="text"
                                   maxlength="30">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">仓库状态：</label>
                        <div class="col-sm-8">
                            <select class="form-control" name="is_current" id="is_current" th:field="*{is_current}"  maxlength="30" required>
                                <option value="Y" selected="true">可用</option>
                                <option value="N">不可用</option>
                            </select>
                        </div>
                    </div>
                </div>

            </div>


                <!--<h4 class="form-header h4">其他信息</h4>-->
                <!--<div class="row">-->
                    <!--<div class="col-sm-12">-->
                        <!--<div class="form-group">-->
                            <!--<label class="col-xs-2 control-label">备注：</label>-->
                            <!--<div class="col-xs-10">-->
                                <!--<textarea name="remark" maxlength="500" th:field="*{remark}" class="form-control" rows="3"></textarea>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
            </form>
    </div>

	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "bas/warehouse";


        function submitHandler() {
            var data = $("#form-user-edit").serializeArray();
            console.log(data)
            //TODO 如果沒有选择项目组（项目组为空 不允许提交）
            $.operate.save(prefix + "/saveAndUpdate", data);
	    }

        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
        	var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
		    var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
   			var body = layer.getChildFrame('body', index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
            selectgroups();
   			layer.close(index);
		}

		$(function() {
            $('#post').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        })
        //分配项目组
        function selectgroups() {
            var deptId = $("#treeId").val();
            var url = ctx + "system/item/selectPrjgroupByDeptId/" + deptId;
            $.get(url, function (result) {
                console.log(result)
                var html = ""
                if(result.length>0){
                    for (var i = 0; i < result.length; i++) {
                        html += "<option  value=" + result[i].prjgroupId + ">" + result[i].prjgroupName + "</option>"
                    }
                }

                $("#prjGroup").html(html)
            })

        }
    </script>
</body>
</html>